أقسام الوصول السريع (مربع البحث)

📁 موضوع هام

آخر المشاركات

document.addEventListener("DOMContentLoaded", function () { // البحث عن النصوص التي تحتوي على صيغة JSON const articles = document.querySelectorAll("p, div, span"); articles.forEach(function (article) { const regex = /\{"DLink":"(b\d+)","DUrl":"(.*?)"\}/g; let match; while ((match = regex.exec(article.innerHTML)) !== null) { const linkType = match[1]; // نوع الزر (b1, b2, ...) const linkUrl = match[2]; // الرابط // إنشاء الزر const button = document.createElement("a"); button.href = linkUrl; button.target = "_blank"; button.className = "button"; // تحديد نوع الزر بناءً على النوع if (linkType === "b1") button.classList.add("button-blue"); if (linkType === "b2") button.classList.add("button-green"); if (linkType === "b3") button.classList.add("button-red"); button.textContent = "اضغط هنا للتحميل"; // استبدال النص بالزرار article.innerHTML = article.innerHTML.replace(match[0], button.outerHTML); } }); });